package com.ygqh.baby.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections4.CollectionUtils;

import com.foxinmy.weixin4j.mp.message.TemplateMessage;
import com.ygqh.baby.po.YgMobile;

public class MsgModel {

	private List<TemplateMessage> wxMsgList;
	private List<YgMobile> mobileMsgList;
	private List<Map<String, String>> appMsgList;

	synchronized private void initWxMsgList() {
		if (CollectionUtils.isEmpty(wxMsgList)) {
			wxMsgList = new ArrayList<TemplateMessage>();
		}
	}

	synchronized private void initMobileMsgList() {
		if (CollectionUtils.isEmpty(mobileMsgList)) {
			mobileMsgList = new ArrayList<YgMobile>();
		}
	}

	synchronized private void initAppMsgList() {
		if (CollectionUtils.isEmpty(appMsgList)) {
			appMsgList = new ArrayList<Map<String, String>>();
		}
	}

	public boolean putWxMsg(TemplateMessage msg) {
		if (CollectionUtils.isEmpty(wxMsgList)) {
			this.initWxMsgList();
		}
		return wxMsgList.add(msg);
	}

	public List<TemplateMessage> getWxMsgList() {
		return wxMsgList;
	}

	public boolean putWxMsgList(List<TemplateMessage> wxMsgList) {
		if (CollectionUtils.isEmpty(wxMsgList)) {
			this.initWxMsgList();
		}
		return wxMsgList.addAll(wxMsgList);
	}

	public List<YgMobile> getMobileMsgList() {
		return mobileMsgList;
	}

	public boolean putMobileMsg(YgMobile mobile) {
		if (CollectionUtils.isEmpty(mobileMsgList)) {
			initMobileMsgList();
		}
		return mobileMsgList.add(mobile);
	}

	public boolean putMobileMsgList(List<YgMobile> mobileMsgList) {
		if (CollectionUtils.isEmpty(mobileMsgList)) {
			initMobileMsgList();
		}
		return mobileMsgList.addAll(mobileMsgList);
	}

	public List<Map<String, String>> getAppMsgList() {
		return appMsgList;
	}

	public boolean putAppMsg(Map<String, String> appMsg) {

		if (CollectionUtils.isEmpty(appMsgList)) {
			initAppMsgList();
		}
		return appMsgList.add(appMsg);
	}

	public boolean putAppMsgList(List<Map<String, String>> appMsgList) {
		if (CollectionUtils.isEmpty(appMsgList)) {
			initAppMsgList();
		}
		return appMsgList.addAll(appMsgList);
	}

}
